package com.atguigu.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Author: 19shusheng.com
 * @Description:
 * @Date: Created in 22:37 2021/1/5
 * @Modified By:
 */
@RestController
@RequestMapping("consumer")
public class OrderNacosController {
    @Resource
    private RestTemplate restTemplate;
    @Value("${service-url.nacos-user-service}")
    private String serverUrl;

    /**
     *
     * @Description:   目的为了检验nacos是否有负载均衡
     *
     * @auther: madonghui
     * @date: 22:42 2021/1/5
     * @param:
     * @return:
     *
     */
    @GetMapping("payment/nacos/{id}")
    public String getServerUrl(@PathVariable String id){
        return restTemplate.getForObject(serverUrl+"/payment/nacos/"+id,String.class);
    }
}
